public class num1155 {
    public int numRollsToTarget(int n, int k, int target) {
        int mod = (int)1e9+7;
        int[][] nums = new int[n + 1][target + 1];
        nums[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= target; j++) {
                for (int l = 1; l <= k; l++) {
                    if(j >= l) {
                    nums[i][j] = (nums[i][j] + nums[i - 1][j - l]) % mod;
                    }
                }
            }
        }
        return nums[n][target];
    }
}
